package cn.myfirefly.moming.portal.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import cn.myfirefly.moming.portal.entity.MMUserSys;
import cn.myfirefly.core.BaseDao;

@Repository
public class UserSysDao extends BaseDao<MMUserSys> {
	
	@SuppressWarnings("unchecked")
	public List<Object> getSysIdsByUserSn(Integer userSn) {
		Session session = getCurrentSession();
		Query query = session.createQuery(" select distinct sysId from MMUserSys where 1=1 and userSn = ? ");
		query.setParameter(0, userSn);
		@SuppressWarnings("rawtypes")
		List list = query.list();
		return list;
	}
	
	public void delete(Integer sysId, Integer userSn) {
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createSQLQuery("delete from mm_user_sys where user_sn = ? and sys_id = ? ");
		query.setParameter(0, userSn);
		query.setParameter(1, sysId);
		query.executeUpdate();
	}
	
}
